home *** CD-ROM | disk | FTP | other *** search
/ Ultimedia 2 / Ultimedia 2.iso / tools / animplayer / amipeg / source.lha / chunky2planar.s < prev    next >
Encoding:
Text File  |  1994-03-03  |  6.6 KB  |  434 lines

  1. ;
  2. ; This source handles the conversion from 24-bit data to HAM8, initialization
  3. ; of the screen and so on.
  4. ;
  5. ; Support for Kaiko is not yet build-in, but very easy to accomplish, as it
  6. ; makes flush_cunkyloop completely obsolete. Looking forward to see
  7. ; custom logic like this, possibly more flexible, built-in in all Amigas.
  8. ;
  9. ; Phew! This one consumes 43% of the overall processor time in hires, 24% in
  10. ; lores. I want this Kaiko thingy!
  11. ;
  12. ;
  13. ; Michael Rausch  13-2-94  8:28:00
  14. ;
  15.  
  16.  
  17.     SECTION    text,CODE
  18.  
  19.     include    "graphics/rastport.i"
  20.     include    "graphics/gfx.i"
  21.  
  22.     XREF    _max_x
  23.     XREF    _max_y
  24.  
  25.  
  26.     XDEF    @HAM8_Init_lores
  27. @HAM8_Init_lores:
  28.     movem.l    d2-d7/a2,-(sp)
  29.  
  30. ;         RGBG  BRGB  R=8 G=C B=4
  31. P7    set    %0111
  32. P8    set    %1101
  33.  
  34.     move.l    #(P7<<28)|(P7<<24)|(P7<<20)|(P7<<16)|(P7<<12)|(P7<<8)|(P7<<4)|P7,d5
  35.     move.l    #(P8<<28)|(P8<<24)|(P8<<20)|(P8<<16)|(P8<<12)|(P8<<8)|(P8<<4)|P8,d6
  36.     bra.s    ham8cont
  37.  
  38.     XDEF    @HAM8_Init
  39. @HAM8_Init:                ; init from rastport data
  40.     movem.l    d2-d7/a2,-(sp)
  41.  
  42. ;         BRGB  R=8 G=C B=4
  43. P7    set    %1011
  44. P8    set    %0110
  45.  
  46.     move.l    #(P7<<28)|(P7<<24)|(P7<<20)|(P7<<16)|(P7<<12)|(P7<<8)|(P7<<4)|P7,d5
  47.     move.l    #(P8<<28)|(P8<<24)|(P8<<20)|(P8<<16)|(P8<<12)|(P8<<8)|(P8<<4)|P8,d6
  48.  
  49. ham8cont:
  50.     move.l    a0,HAM8_rastport
  51.     move.l    (rp_BitMap,a0),a0
  52.     moveq    #0,d1
  53.     move.w    (bm_BytesPerRow,a0),d1
  54.     move.l    (bm_Planes,a0),a1
  55.     move.l    a1,HAM8_screen
  56.     move.l    (bm_Planes+4,a0),a2
  57.     sub.l    a1,a2            ; plane delta
  58.  
  59.     cmp.l    a2,d1
  60.     bgt.s    check_interleaved
  61.     sub.l    a2,a2            ; RED ALERT, no interlaved bitmap or strange, weirdo layout!
  62. check_interleaved:
  63.     move.l    a2,HAM8_next
  64.     move.l    d1,HAM8_offset        ; we have advanced one complete line when accessing this
  65.  
  66.     moveq.l    #0,d4
  67.  
  68.     move.l    a2,d1
  69.     lsr.l    #2,d1            ; longs
  70.     subq.l    #1,d1
  71.  
  72.     move.w    (bm_Rows,a0),d0
  73.     subq.w    #1,d0
  74. prep_rows:
  75.  
  76.     move.l    d1,d2
  77. prep_nulls:
  78.     move.l    d4,(a1)+
  79.     move.l    d4,(a1)+
  80.     move.l    d4,(a1)+
  81.     move.l    d4,(a1)+
  82.     move.l    d4,(a1)+
  83.     move.l    d4,(a1)+
  84.     dbra    d2,prep_nulls
  85.  
  86.     move.l    a1,a0
  87.     add.l    a2,a0
  88.  
  89.     move.l    d1,d2
  90.     lsr.l    #1,d2            ; ohoh
  91. prep_cols67:
  92.     move.l    d5,(a1)+
  93.     move.l    d5,(a1)+
  94.     move.l    d6,(a0)+
  95.     move.l    d6,(a0)+
  96.     dbra    d2,prep_cols67
  97.  
  98.     add.l    a2,a1
  99.     dbra    d0,prep_rows
  100.  
  101.     movem.l    (sp)+,d2-d7/a2
  102.     rts
  103.  
  104.  
  105. ********************************************************
  106.  
  107.  
  108.     XDEF    @HAM8_draw_lores    ;     (data=a0, x=d0, y=d1)
  109. @HAM8_draw_lores:
  110.     movem.l    d2-d7/a2-a6,-(sp)
  111.  
  112.     move.l    _max_y(a4),d7
  113.     cmp.l    d7,d1
  114.     bge.s    max128lores
  115.     move.l    d1,d7        ; height
  116. max128lores:
  117.     subq.l    #1,d7
  118.  
  119.     move.l    _max_x(a4),d1
  120.     cmp.l    d1,d0
  121.     bge.s    max160lores
  122.     move.l    d0,d1        ; width
  123. max160lores:
  124.  
  125.     move.l    d1,d6
  126.     lsr.w    #4,d6
  127.     subq.w    #1,d6        ; width in 8 pixel chunks
  128.  
  129.     and.w    #$fff0,d1    ; correct eol of over-large pix
  130.     sub.l    d1,d0
  131.  
  132.     move.l    d0,d2        ; this is some quick fix for 360 pixels wide b0.mpg, which is invalid!
  133.     and.w    #8,d2
  134.     add.w    d2,d0
  135.  
  136.     add.l    d0,d0        ; 1 word per pixel
  137.     move.l    d0,line_offset
  138.  
  139.  
  140.     move.l    HAM8_screen,a1    ; get addr, prep next line
  141.     move.l    HAM8_next,d1
  142.     move.l    a1,a2
  143.     add.l    d1,a2
  144.     move.l    a2,a3
  145.     add.l    d1,a3
  146.     move.l    a3,a4
  147.     add.l    d1,a4
  148.     move.l    a4,a5
  149.     add.l    d1,a5
  150.     move.l    a5,a6
  151.     add.l    d1,a6
  152.  
  153.     move.l    HAM8_offset,d2
  154.     move.l    d6,d0
  155.     addq.l    #1,d0
  156.     lsl.l    #2,d0        ; writing one long per main loop
  157.     sub.l    d0,d2
  158.     move.l    d2,draw_offset
  159.  
  160.  
  161.  
  162. draw_all_rows_lores:
  163.  
  164.     move.l    d7,-(sp)        ; a2 a3 a4 a5 a6 actually unused
  165.     move.l    d6,-(sp)
  166.  
  167.  
  168.     
  169. blocks_loop_lores:
  170.     move.l    d6,-(sp)
  171.  
  172.     moveq    #7,d6
  173. flush_chunkyloop_lores:
  174.     move.l    (a0)+,d7        ; RGBG
  175.  
  176.     add.l    d7,d7
  177.     addx.l    d0,d0
  178.     add.l    d7,d7
  179.     addx.l    d1,d1
  180.     add.l    d7,d7
  181.     addx.l    d2,d2
  182.     add.l    d7,d7
  183.     addx.l    d3,d3
  184.     add.l    d7,d7
  185.     addx.l    d4,d4
  186.     add.l    d7,d7
  187.     addx.l    d5,d5
  188.  
  189.     lsl.l    #3,d7
  190.     addx.l    d0,d0
  191.     add.l    d7,d7
  192.     addx.l    d1,d1
  193.     add.l    d7,d7
  194.     addx.l    d2,d2
  195.     add.l    d7,d7
  196.     addx.l    d3,d3
  197.     add.l    d7,d7
  198.     addx.l    d4,d4
  199.     add.l    d7,d7
  200.     addx.l    d5,d5
  201.  
  202.     lsl.l    #3,d7
  203.     addx.l    d0,d0
  204.     add.l    d7,d7
  205.     addx.l    d1,d1
  206.     add.l    d7,d7
  207.     addx.l    d2,d2
  208.     add.l    d7,d7
  209.     addx.l    d3,d3
  210.     add.l    d7,d7
  211.     addx.l    d4,d4
  212.     add.l    d7,d7
  213.     addx.l    d5,d5
  214.  
  215.     lsl.l    #3,d7
  216.     addx.l    d0,d0
  217.     add.l    d7,d7
  218.     addx.l    d1,d1
  219.     add.l    d7,d7
  220.     addx.l    d2,d2
  221.     add.l    d7,d7
  222.     addx.l    d3,d3
  223.     add.l    d7,d7
  224.     addx.l    d4,d4
  225.     add.l    d7,d7
  226.     addx.l    d5,d5
  227.  
  228.     dbra    d6,flush_chunkyloop_lores
  229.     
  230.     move.l    d5,(a1)+
  231.     move.l    d4,(a2)+
  232.     move.l    d3,(a3)+
  233.     move.l    d2,(a4)+
  234.     move.l    d1,(a5)+
  235.     move.l    d0,(a6)+
  236.  
  237.     move.l    (sp)+,d6
  238.     dbra    d6,blocks_loop_lores
  239.  
  240.     add.l    line_offset,a0
  241.  
  242.     move.l    draw_offset,d1
  243.     add.l    d1,a1
  244.     add.l    d1,a2
  245.     add.l    d1,a3
  246.     add.l    d1,a4
  247.     add.l    d1,a5
  248.     add.l    d1,a6
  249.  
  250.     move.l    (sp)+,d6
  251.     move.l    (sp)+,d7
  252.     dbra    d7,draw_all_rows_lores
  253.  
  254.  
  255.     movem.l    (sp)+,d2-d7/a2-a6
  256.     rts
  257.  
  258.  
  259. ********************************************************
  260.  
  261.  
  262.     XDEF    @HAM8_draw_hires    ; (data=a0, x=d0, y=d1)
  263. @HAM8_draw_hires:
  264.     movem.l    d2-d7/a2-a6,-(sp)
  265.  
  266.     move.l    _max_y(a4),d7
  267.     cmp.l    d7,d1
  268.     bge.s    max128
  269.     move.l    d1,d7        ; height
  270. max128:    subq.l    #1,d7
  271.  
  272.     move.l    _max_x(a4),d1
  273.     cmp.l    d1,d0
  274.     bge.s    max160
  275.     move.l    d0,d1        ; width
  276. max160:
  277.  
  278.     move.l    d1,d6
  279.     lsr.w    #3,d6
  280.     subq.w    #1,d6        ; width in 8 pixel chunks
  281.  
  282.     and.w    #$fff8,d1    ; correct eol of over-large pix
  283.     sub.l    d1,d0
  284.     lsl.l    #2,d0        ; 1 long per pixel
  285.     move.l    d0,line_offset
  286.  
  287.  
  288.     move.l    HAM8_screen,a1        ; get addr, prep next line
  289.     move.l    HAM8_next,d1
  290.     move.l    a1,a2
  291.     add.l    d1,a2
  292.     move.l    a2,a3
  293.     add.l    d1,a3
  294.     move.l    a3,a4
  295.     add.l    d1,a4
  296.     move.l    a4,a5
  297.     add.l    d1,a5
  298.     move.l    a5,a6
  299.     add.l    d1,a6
  300.  
  301.     move.l    HAM8_offset,d2
  302.     move.l    d6,d0
  303.     addq.l    #1,d0
  304.     lsl.l    #2,d0
  305.     sub.l    d0,d2
  306.     move.l    d2,draw_offset
  307.  
  308.  
  309.  
  310. draw_all_rows:
  311.  
  312.     move.l    d7,-(sp)        ; a2 a3 a4 a5 a6 actually unused
  313.     move.l    d6,-(sp)
  314.  
  315.  
  316.     
  317. blocks_loop:
  318.     move.l    d6,-(sp)
  319.  
  320.     moveq    #7,d6
  321. flush_chunkyloop:
  322.     move.l    (a0)+,d7        ; BRG0
  323.  
  324.     add.l    d7,d7
  325.     addx.l    d0,d0
  326.     add.l    d7,d7
  327.     addx.l    d1,d1
  328.     add.l    d7,d7
  329.     addx.l    d2,d2
  330.     add.l    d7,d7
  331.     addx.l    d3,d3
  332.     add.l    d7,d7
  333.     addx.l    d4,d4
  334.     add.l    d7,d7
  335.     addx.l    d5,d5
  336.  
  337.     lsl.l    #3,d7
  338.     addx.l    d0,d0
  339.     add.l    d7,d7
  340.     addx.l    d1,d1
  341.     add.l    d7,d7
  342.     addx.l    d2,d2
  343.     add.l    d7,d7
  344.     addx.l    d3,d3
  345.     add.l    d7,d7
  346.     addx.l    d4,d4
  347.     add.l    d7,d7
  348.     addx.l    d5,d5
  349.  
  350.     lsl.l    #3,d7
  351.     addx.l    d0,d0
  352.     add.l    d7,d7
  353.     addx.l    d1,d1
  354.     add.l    d7,d7
  355.     addx.l    d2,d2
  356.     add.l    d7,d7
  357.     addx.l    d3,d3
  358.     add.l    d7,d7
  359.     addx.l    d4,d4
  360.     add.l    d7,d7
  361.     addx.l    d5,d5
  362.  
  363.     add.l    d0,d0
  364.     add.l    d1,d1
  365.     add.l    d2,d2
  366.     add.l    d3,d3
  367.     add.l    d4,d4
  368.     add.l    d5,d5
  369.  
  370.     dbra    d6,flush_chunkyloop
  371.  
  372.  
  373.     move.l    #$11111111,d6
  374. copcol    macro    (reg)
  375.     move.l    \1,d7
  376.     lsr.l    #3,d7            ; BRGB
  377.     and.l    d6,d7
  378.     or.l    d7,\1
  379.     endm
  380.     copcol    d0
  381.     copcol    d1
  382.     copcol    d2
  383.     copcol    d3
  384.     copcol    d4
  385.     copcol    d5
  386.     
  387.     move.l    d5,(a1)+
  388.     move.l    d4,(a2)+
  389.     move.l    d3,(a3)+
  390.     move.l    d2,(a4)+
  391.     move.l    d1,(a5)+
  392.     move.l    d0,(a6)+
  393.  
  394.     move.l    (sp)+,d6
  395.     dbra    d6,blocks_loop
  396.  
  397.     add.l    line_offset,a0
  398.  
  399.     move.l    draw_offset,d1
  400.     add.l    d1,a1
  401.     add.l    d1,a2
  402.     add.l    d1,a3
  403.     add.l    d1,a4
  404.     add.l    d1,a5
  405.     add.l    d1,a6
  406.  
  407.     move.l    (sp)+,d6
  408.     move.l    (sp)+,d7
  409.     dbra    d7,draw_all_rows
  410.  
  411.  
  412.     movem.l    (sp)+,d2-d7/a2-a6
  413.     rts
  414.  
  415.  
  416. ********************************************************
  417.  
  418.  
  419.  
  420.  
  421.     SECTION    bss,BSS
  422.  
  423.  
  424. HAM8_rastport:    ds.l    1            ; original rastport struct
  425. HAM8_screen:    ds.l    1            ; first bitplane
  426. HAM8_offset:    ds.l    1            ; next line in the first bitplane
  427. HAM8_next:    ds.l    1            ; next bitplane
  428.  
  429.  
  430. draw_offset:    ds.l    1
  431. line_offset:    ds.l    1
  432.  
  433.     END
  434.